Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unexpected exception on assigning labels on host networks #892

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

sermakov-orion
Copy link
Contributor

Signed-off-by: Stepan Ermakov sermakov@orionsoft.ru

Changes introduced with this PR

This PR fixes the following issue: an error occurs while assigning labels on host network interfaces: "Error while executing action HostSetupNetworks: Unexpected exception"
Steps to reproduce:

  1. Open "Compute->Hosts". List of hosts will be displayed.
  2. Click on any host and select "Network Interfaces" tab. Network interfaces of the selected host will be displayed.
  3. Click on "Setup Host Networks". "Setup Host Networks" modal dialog will be displayed.
  4. Click on "Labels". Labels of the host networks will be displayed.
  5. Drag-n-drop "New Label" on any network interface. Enter new label name and click "OK". New label will be added to the selected network.
  6. Click "OK" in the "Setup Host Networks" modal dialog.

Expected behavior
The changes applied with no errors
Current behavior
The error message is displayed: "Error while executing action HostSetupNetworks: Unexpected exception". The new label was not added to the host network.

Background

  1. The HostSetupNetworksCommand verifies if there are changes made in the "Setup Host Networks" modal dialog (see HostSetupNetworksCommand.executeCommand, if (noChangesDetected()) statement).
  2. Since there are some changes (labels were added) it makes the HostSetupNetworks call to the host VDSM but passes empty payload inside the call (because there were no real changes of networks, just labels were changed). And VDSM fails with the Unexpected Error on the empty payload.
  3. In this PR I introduced additional check if (hasNetworkChanges()) that verifies whether the HostSetupNetworks call to the host VDSM is needed or not.

Are you the owner of the code you are sending in, or do you have permission of the owner?

y

@michalskrivanek
Copy link
Member

LGTM though i'm not sure about the completeness of the changes that need to go to the actual host, @almusil wdyt?

@sermakov-orion
Copy link
Contributor Author

@michalskrivanek let me add bit more clarity on why I decided not to go to the actual host in case when there no changes other than labels. The HostSetupNetworks VDSM command is invoked with parameters created by the HostSetupNetworksCommand.createSetupNetworksParameters method. And if you walk through this and underlying methods you may notice that they use everything from getParameters() but not getParametes().getLables() and getParameters().getRemovedLables(). So, It looks that HostSetupNetworks does not require any changes in labels.

Copy link
Member

@almusil almusil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

thank you for the patch. Please add an explanation to the commit message so it is clear in the history why this change was required.


if (succeeded) {
setSucceeded(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setSucceeded(true) can be moved to the if above when there is only single boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if (retVal != null) {
if (!retVal.getSucceeded() && retVal.getVdsError() == null && getParameters().rollbackOnFailure()) {
throw new EngineException(EngineError.SETUP_NETWORKS_ROLLBACK, retVal.getExceptionString());
boolean networksUpdated = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need only single boolean. The fact that we have propagated succeed even if retVal.getSucceeded() == false seems to be a mistake. That was introduced by 28f34a4.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@almusil this significantly simplifies the proposed changes. Thanks a lot! Will do it soon - it may take a while to verify the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can flip the succeeded logic to avoid this else branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

boolean succeeded = false;

if (hasNetworkChanges()) {
//Update networks configuration on the host
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add space after // and period at the end, that applies to all comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Signed-off-by: Stepan Ermakov <sermakov@orionsoft.ru>

This PR fixes the following issue: an error occurs while assigning labels on host network interfaces: "Error while executing action HostSetupNetworks: Unexpected exception"

Steps to reproduce:

    1. Open "Compute->Hosts". List of hosts will be displayed.
    2. Click on any host and select "Network Interfaces" tab. Network interfaces of the selected host will be displayed.
    3. Click on "Setup Host Networks". "Setup Host Networks" modal dialog will be displayed.
    4. Click on "Labels". Labels of the host networks will be displayed.
    5. Drag-n-drop "New Label" on any network interface. Enter new label name and click "OK". New label will be added to the selected network.
    6. Click "OK" in the "Setup Host Networks" modal dialog.

Expected behavior:
    The changes applied with no errors
Current behavior:
    The error message is displayed: "Error while executing action HostSetupNetworks: Unexpected exception". The new label was not added to the host network.

Background:
    The HostSetupNetworksCommand verifies if there are changes made in the "Setup Host Networks" modal dialog (see HostSetupNetworksCommand.executeCommand, "if (noChangesDetected())" statement).
    Since there are some changes (labels were added) it makes the HostSetupNetworks call to the host VDSM but passes empty payload inside the call (because there were no real changes of networks, just labels were changed). And VDSM fails with the Unexpected Error on the empty payload.
    In this PR I introduced additional check "if (hasNetworkChanges())" that verifies whether the HostSetupNetworks call to the host VDSM is needed or not.
@sermakov-orion
Copy link
Contributor Author

Hi,

thank you for the patch. Please add an explanation to the commit message so it is clear in the history why this change was required.

Hi @almusil.
I did this change as well as other mentioned here. Could you please do another round of the review?

Copy link
Member

@almusil almusil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! @michalskrivanek do we want to run ost? It will most likely fail in the UI tests though.

@almusil
Copy link
Member

almusil commented Nov 27, 2023

/ost

@almusil
Copy link
Member

almusil commented Nov 27, 2023

/ost basic-suite-master el9stream

@almusil almusil merged commit 9fa9d7d into oVirt:master Nov 27, 2023
4 checks passed
@sermakov-orion sermakov-orion deleted the host-network-labels branch November 28, 2023 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants